package com.example.demo.util;

import com.example.demo.config.BeanFactory;

/**
 * @Description:
 * @author: fanfan
 * @date: 2019/3/20 14:33
 */
public class MDCHelper {
    static final String NULL_MDCA_URL = "http://www.slf4j.org/codes.html#null_MDCA";

    public static void put(String key, String val) throws IllegalArgumentException {
        MDCAdapter mdcAdapter = BeanFactory.getBean(MDCAdapter.class);
        if (key == null) {
            throw new IllegalArgumentException("key parameter cannot be null");
        }
        if (mdcAdapter == null) {
            throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
        }
        mdcAdapter.put(key, val);
    }
}
